<?php
namespace app\user\model;
use app\common\library\Model;

class UserDistributor extends Model
{

    protected $append = [
        'status_name',
//        'license_pic',
//        'idcard_pic',
//        'works_pic',
    ];

//    public function getLicensePicAttr($value, $data) {
//        return $value ? explode(",", $value) : [];
//    }
//
//    public function getIdcardPicAttr($value, $data) {
//        return $value ? explode(",", $value) : [];
//    }
//
//    public function getWorksPicAttr($value, $data) {
//        return $value ? explode(",", $value) : [];
//    }


    public function getStatusNameAttr($value, $data) {
        $config = config('user.user_distributor_field_status');
        return $config[$data['status']];
    }

    public function user() {
    	return $this->hasOne('app\\user\\model\\User','id', 'uid');
    }

    public function customer() {
        return $this->hasOne("app\\user\\model\\user", 'id', 'customer_id');
    }

}